<?php 
	$id = $_POST['kelas'];
	$jenis = "$_POST[jenis]";
	
	include ("../../config/koneksi.php");
	if($jenis == 'all'){
		$q = "select * from tarif_inacbg t inner join master_inacbg m on m.kode_inacbg = t.kode_inacbg where id_kelas_tarif = $id";
	}else{
		$q = "select * from tarif_inacbg t inner join master_inacbg m on m.kode_inacbg = t.kode_inacbg where id_kelas_tarif = $id and id_jenis_inacbg = $jenis";
		$jns = mysql_fetch_array(mysql_query("select * from jenis_inacbg where id_jenis_inacbg = $jenis"));
	}
	$r = mysql_query($q);
	
	$kelas = mysql_fetch_array(mysql_query("select kelas_tarif from kelas_tarif where id_kelas_tarif = $id"));
	
	$content = "DAFTAR TARIF INACBG ".strtoupper($jns['jenis_inacbg'])."\nKELAS : $kelas[kelas_tarif]\n\nNO;KODE;DESKRIPSI;ALOS;TARIF\n";
	while ($data = mysql_fetch_array($r)) {
		$no++;
		$content .= "$no;$data[kode_inacbg];$data[deskripsi];$data[alos];$data[tarif_inacbg]\n";
	};

	header("Content-type: text/csv");
	header("Content-Disposition: attachment; filename=tarif_inacbg.csv");
	header("Pragma: no-cache");
	header("Expires: 0");
	echo $content;
?>